package com.dao.impl;

import java.io.Serializable;
import java.util.List;

import org.hibernate.Query;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.dao.AreausableDao;
import com.enetiy.Areausable;
import com.enetiy.Binding;
import com.enetiy.Comboinfo;
import com.enetiy.Netclick;

public class AreausableDaoImpl extends HibernateDaoSupport implements
		AreausableDao {

	@Override
	public List<Areausable> selectAreabList(int siareaid) throws Exception {
		
		Query query = this.getSession().createQuery("from Areausable where area_id=?");	
		query.setParameter(0, siareaid);
		List <Areausable>list = query.list();
		return list;
	}

	@Override
	public Areausable selectAreausable(int sidearea, int areainfoid) {
		Query query = this.getSession().createQuery("from Areausable where area_id=? and areainfo_id=?");
		query.setParameter(0, sidearea);
		query.setParameter(1, areainfoid);
		List <Areausable>list = query.list();
		return list.isEmpty()?null:list.get(0);
	}

	@Override
	public Serializable insertNetclick(Netclick netclick) throws Exception {
		return this.getHibernateTemplate().save(netclick);
	}

	@Override
	public List<Areausable> selectAreabList(int siareaid, int isShow)
			throws Exception {
		Query query = this.getSession().createQuery("from Areausable where area_id=? and is_show=?");	
		query.setParameter(0, siareaid);
		query.setParameter(1, isShow);
		List <Areausable>list = query.list();
		return list;
	}

	

}
